# 导包
import app
import script.interface_login
import requests
# 创建接口类

class employee_API():


    def __init__(self):
        self.emp_url = app.BASE_URL+"api/sys/user"
        self.updata_url = app.BASE_URL+"api/sys/user/{}"
        self.select_url = app.BASE_URL+"api/sys/user/{}"
        self.de_url = app.BASE_URL+"api/sys/user/{}"

        file = "./tools/app.txt"
        TOKEN = open(file, "r").read()

        self.header_data = {
            "Content-Type": "application/json",
            "Authorization": TOKEN
        }


    def add_emp(self,add_emp_data):
        response =requests.post(url=self.emp_url,json=add_emp_data,headers= self.header_data)
        return  response

    def updata_emp(self,employee_id,updata_emp_data,):
        up_data_url = self.updata_url.format(employee_id)
        response = requests.put(url=up_data_url, json=updata_emp_data, headers=self.header_data)
        return response

    def get_emp(self,employee_id):
        select_url = self.select_url.format(employee_id)
        return requests.get(url=select_url,headers = self.header_data)

    def de_emp(self,employee_id):
        select_url = self.de_url.format(employee_id)
        return requests.delete(url=select_url,headers = self.header_data)





